import { _decorator, Component, Node, Label } from "cc";
import request from "../../utils/request";
const { ccclass, property } = _decorator;

@ccclass("Game/UI/UserInfo")
export class UserInfo extends Component {
    @property(Label)
    private userId: Label = null;

    @property(Label)
    private nickName: Label = null;

    start() {
        const token = localStorage.getItem("token");
        if (token) {
            request.post("/users/userinfo", { token }).then(({ code, data }) => {
                if (code !== "0000") return;
                this.userId.string = `id:${data.userId}`;
                this.nickName.string = data.nickName;
            });
        }
    }
}
